(function() {
    var lastTime = 0;

    window.rAF = function(callback, element) {
        var currTime = new Date().getTime();
        var timeToCall = Math.max(0, 16 - (currTime - lastTime));
        var id = window.setTimeout(function() { callback(currTime + timeToCall); },
            timeToCall);
        lastTime = currTime + timeToCall;
        return id;
    };

    window.cAF = function(id) {
        clearTimeout(id);
    };
}());
